"""Build container library"""


def scons():
    """Execute build"""
    Import('env', 'prereqs', 'libdaos_tgts')

    env.AppendUnique(LIBPATH=[Dir('.')])
    denv = env.Clone()

    denv.require('protobufc')

    common = denv.SharedObject(['rpc.c'])

    # dc_cont: Container Client
    libdaos_tgts.extend(denv.SharedObject(['cli.c']) + common)

    if not prereqs.server_requested():
        return

    # ds_cont: Container Server
    senv = denv.Clone()
    senv.require('argobots', 'pmdk', headers_only=True)
    senv.Append(CPPDEFINES=['-DDAOS_PMEM_BUILD'])
    ds_cont = senv.d_library('cont',
                             ['srv.c', 'srv_container.c', 'srv_epoch.c',
                              'srv_target.c', 'srv_layout.c', 'oid_iv.c',
                              'container_iv.c', 'srv_cli.c', 'srv_oi_table.c',
                              'srv_metrics.c', common],
                             install_off="../..")
    senv.Install('$PREFIX/lib64/daos_srv', ds_cont)


if __name__ == "SCons.Script":
    scons()
